package com.ccsoft.netty.heartbeat.client;

/**
 * @author chanchaw
 * @create 2022-07-20 16:45
 */
public interface RetryPolicy {
    /**
     * Called when an operation has failed for some reason. This method should return
     * true to make another attempt.
     * 传入当前重试的次数，比对初始化时设定的最大重试次数，超过则返回 false 表示不再重试
     * 相反，返回 true 表示可以继续重试
     * @param retryCount the number of times retried so far (0 the first time)
     * @return true/false
     */
    boolean allowRetry(int retryCount);

    /**
     * get sleep time in ms of current retry count.
     * 根据当前重试的次数，返回睡眠的时长（毫秒）
     * @param retryCount current retry count
     * @return the time to sleep
     */
    long getSleepTimeMs(int retryCount);
}
